package com.chanzany.state.case2;

import lombok.Getter;
import lombok.Setter;

/**
 * @Author ChanZany
 * @Date 2021/10/20 14:39
 * @Version 1.0
 */
//环境类
@Setter
@Getter
class ThreadContext {
    private ThreadState state;
    ThreadContext(){
        state = new New();
    }
    public void start(){
        ((New) state).start(this);
    }
    public void getCPU(){
        ((Runnable) state).getCPU(this);
    }
    public void suspend(){
        ((Running) state).suspend(this);
    }
    public void stop(){
        ((Running) state).stop(this);
    }
    public void resume(){
        ((Blocked) state).resume(this);
    }
}
